home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / bbs / cddk9606.zip / HEADERS.ARJ / XDOS.INT < prev    next >
Text File  |  1996-06-14  |  19KB  |  730 lines

  1.  
  2. { ───────────────────────────────────────────────────────────────────────── }
  3. {  XDOS: Extended DOS unit                                                  }
  4. {  Copyright 1996 David Pinch ∙ All Rights Reserved Worldwide               }
  5. { ───────────────────────────────────────────────────────────────────────── }
  6.  
  7. UNIT xDOS;
  8.  
  9. {$B-} { . . . . . . . . . . . . . . . . . . . . Shortcut boolean evaluation }
  10. {$F+} { . . . . . . . . . . . . . . . . . . . .  Force far calls for safety }
  11. {$I-} { . . . . . . . . . . . . . . . . . . . Disable input/output checking }
  12. {$O+} { . . . . . . . . . . . . . . . . . . Allow this unit to be overlayed }
  13. {$Q-} { . . . . . . . . . . . . . .  Do not generate overflow-checking code }
  14. {$R-} { . . . . . . . . . . . . . . . . Do not generate range-checking code }
  15. {$S-} { . . . . . . . . . . . . . . . . Do not generate stack-checking code }
  16. {$X+} { . . . . . . . . . . . Extended syntax for pChars and function calls }
  17.  
  18. INTERFACE
  19.  
  20. CONST
  21.  
  22.   { CPU Flags }
  23.  
  24.   fCarry     = $0001;  { ........ .......1 }
  25.   fParity    = $0004;  { ........ .....1.. }
  26.   fAuxiliary = $0010;  { ........ ...1.... }
  27.   fZero      = $0040;  { ........ .1...... }
  28.   fSign      = $0080;  { ........ 1....... }
  29.   fOverflow  = $0800;  { 1....... ........ }
  30.  
  31.  
  32.   { DOS Memory }
  33.  
  34.   dmRAM       = $00;   { .....0.. }
  35.   dmROM       = $04;   { .....1.. }
  36.   dmConv      = $00;   { ....0... }
  37.   dmHigh      = $08;   { ....1... }
  38.  
  39.  
  40.   { File Attributes }
  41.  
  42.   faNormal    = $00;   { ........ }
  43.   faReadOnly  = $01;   { .......1 }
  44.   faHidden    = $02;   { ......1. }
  45.   faSysFile   = $04;   { .....1.. }
  46.   faVolumeID  = $08;   { ....1... }
  47.   faDirectory = $10;   { ...1.... }
  48.   faArchive   = $20;   { ..1..... }
  49.   faAnyFile   = $3F;   { ..111111 }
  50.  
  51.  
  52.   { File Contains... }
  53.  
  54.   fcExtension = $0001; { .......1 }
  55.   fcFileName  = $0002; { ......1. }
  56.   fcDirectory = $0004; { .....1.. }
  57.   fcWildcards = $0008; { ....1... }
  58.  
  59.  
  60.   { File Modes }
  61.  
  62.   fmReadOnly  = $00;   { .....000 }
  63.   fmWriteOnly = $01;   { .....001 }
  64.   fmReadWrite = $02;   { .....010 }
  65.   fmCompat    = $00;   { .000.... }
  66.   fmDenyAll   = $10;   { .001.... }
  67.   fmDenyWrite = $20;   { .010.... }
  68.   fmDenyRead  = $30;   { .011.... }
  69.   fmDenyNone  = $40;   { .100.... }
  70.   fmNoInherit = $70;   { 1....... }
  71.  
  72.  
  73.   { Filespec Lengths }
  74.  
  75.   fsPathName  = 79;
  76.   fsDirectory = 67;
  77.   fsFileName  = 08;
  78.   fsExtension = 04;
  79.  
  80.  
  81.   { Standard File Modes }
  82.  
  83.   fmClosed = $D7B0;
  84.   fmInput  = $D7B1;
  85.   fmOutput = $D7B2;
  86.   fmInOut  = $D7B3;
  87.  
  88.  
  89. TYPE
  90.  
  91.   { FileSpec Strings }
  92.  
  93.   PathStr = ARRAY[0..fsPathName]  OF Char;
  94.   DirStr  = ARRAY[0..fsDirectory] OF Char;
  95.   NameStr = ARRAY[0..fsFileName]  OF Char;
  96.   ExtStr  = ARRAY[0..fsExtension] OF Char;
  97.  
  98.  
  99.   { BIOS Support }
  100.  
  101.   tBIOS = RECORD
  102.     SerialPort        : ARRAY [0..3] OF Word;
  103.     ParallelPort      : ARRAY [0..3] OF Word;
  104.     EquipFlags        : Word;
  105.     MfgrTestFlags     : Byte;
  106.     MainMem           : Word;
  107.     ExpRam            : Word;
  108.     KbdStat           : Word;
  109.     KeyPad            : Byte;
  110.     KbdBuffHead       : Word;
  111.     KbdBuffTail       : Word;
  112.     KbdBuff           : ARRAY [0..31] OF Char;
  113.     SeekStatus        : Byte;
  114.     MortotStatus      : Byte;
  115.     MortoCnt          : Byte;
  116.     DiskError         : Byte;
  117.     NECStatus         : ARRAY [0..6] OF Byte;
  118.     VideoMode         : Byte;
  119.     ScreenWidth       : Word;
  120.     VideoBufferSize   : Word;
  121.     VideoBufferOfs    : Word;
  122.     CursorPos         : ARRAY [0..7,0..1] OF Byte;
  123.     CursorBottom      : Byte;
  124.     CursorTop         : Byte;
  125.     ActiveDisplayPage : Byte;
  126.     ActiveDisplayPort : Word;
  127.     CRTModeReg        : Byte;
  128.     Palette           : Byte;
  129.     DataEdgeTimeCount : Word;
  130.     CRCReg            : Word;
  131.     LastCharInput     : Char;
  132.     Tick              : Word;
  133.     Hour              : Integer;
  134.     TimerOverFlow     : Byte;
  135.     BreakStatus       : Byte;
  136.     ResetFlag         : Word;
  137.     HardDiskStatus    : LongInt;
  138.     ParallelTimeout   : ARRAY[0..3] OF Byte;
  139.     SerialTimeout     : ARRAY[0..3] OF Byte;
  140.     KbdBufferOfs      : Word;
  141.     KbdBufferEnd      : Word;
  142.     END;
  143.  
  144.   pBIOS = ^tBIOS;
  145.  
  146.   tDateTime = RECORD
  147.     Year  : Word;
  148.     Month : Word;
  149.     Day   : Word;
  150.     Hour  : Word;
  151.     Min   : Word;
  152.     Sec   : Word;
  153.     END;
  154.  
  155.   pDateTime = ^tDateTime;
  156.  
  157.   tRegisters = RECORD
  158.     CASE Integer OF
  159.       0 : (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: Word);
  160.       1 : (AL, AH, BL, BH, CL, CH, DL, DH: Byte);
  161.     END;
  162.  
  163.   pRegisters = ^tRegisters;
  164.  
  165.   tSearchRec = RECORD
  166.     Fill : ARRAY[1..21] OF Byte;
  167.     Attr : Byte;
  168.     Time : Longint;
  169.     Size : Longint;
  170.     Name : ARRAY[0..12] OF Char;
  171.     END;
  172.  
  173.   pSearchRec = ^tSearchRec;
  174.  
  175.   SO = RECORD    { Segment:Offset }
  176.     S : Word;
  177.     O : Word;
  178.     END;
  179.  
  180. { ----------------------------- }
  181. {  TurboPascal File Structures  }
  182. { ----------------------------- }
  183.  
  184.   tFileRec = RECORD
  185.     Handle   : Word;
  186.     Mode     : Word;
  187.     RecSize  : Word;
  188.     PrivData : ARRAY[1..26] OF Byte;
  189.     UserData : ARRAY[1..16] OF Byte;
  190.     Name     : ARRAY[0..79] OF Char;
  191.     END;
  192.  
  193.   tTextBuf = ARRAY[0..127] OF Char;
  194.  
  195.   pTextBuf = ^tTextBuf;
  196.  
  197.   tTextRec = RECORD
  198.     Handle    : Word;
  199.     Mode      : Word;
  200.     BufSize   : Word;
  201.     PrivData  : Word;
  202.     BufPos    : Word;
  203.     BufEnd    : Word;
  204.     BufPtr    : pTextBuf;
  205.     OpenFunc  : Pointer;
  206.     InOutFunc : Pointer;
  207.     FlushFunc : Pointer;
  208.     CloseFunc : Pointer;
  209.     UserData  : ARRAY[1..16] OF Byte;
  210.     Name      : ARRAY[0..79] OF Char;
  211.     Buffer    : tTextBuf;
  212.     END;
  213.  
  214.  
  215. CONST
  216.  
  217.   CommandLine  : STRING[127] = '';
  218.  
  219.   Days : ARRAY[1..12] OF Byte = (31,28,31,30,31,30,31,31,30,31,30,31);
  220.  
  221.   FileNameSet : SET OF Char =
  222.     ['!','#'..')',#45,#46,'0'..':','@'..'Z','\','`'..#123,#125,'~','_'];
  223.  
  224.   Reserved_Name : ARRAY[1..14] OF STRING[8] = (
  225.     {01} 'AUX',         { Auxiliary device        }
  226.     {02} 'CLOCK$',      { System clock            }
  227.     {03} 'COM1',        { Communications port 1   }
  228.     {04} 'COM2',        { Communications port 2   }
  229.     {05} 'COM3',        { Communications port 3   }
  230.     {06} 'COM4',        { Communications port 4   }
  231.     {07} 'CON',         { Console                 }
  232.     {08} 'EMMXXXX0',    { Expanded Memory Manager }
  233.     {09} 'LPT1',        { Parallel port 1         }
  234.     {10} 'LPT2',        { Parallel port 2         }
  235.     {11} 'LPT3',        { Parallel port 3         }
  236.     {12} 'NUL',         { Nul output device       }
  237.     {13} 'PRN',         { Printer                 }
  238.     {14} 'XMSXXXX0');   { Extended Memory Manager }
  239.  
  240. CONST
  241.   DOSError : Integer = 0;
  242.  
  243. VAR
  244.   BIOS     : tBIOS ABSOLUTE Seg0040;
  245.   IPCA     : ARRAY[1..16] OF Byte ABSOLUTE $0000:$04F0;
  246.   Ticks    : LongInt ABSOLUTE $0040:$006C;
  247.  
  248.  
  249. {#Start}
  250.  
  251. FUNCTION AppendSlash(p:pChar):pChar;
  252.   {
  253.   PURPOSE  : Appends a slash to the directory name.
  254.  
  255.   NOTES    : A slash is not appended if the string is empty.  An empty
  256.              directory path generally implies the current directory, not
  257.              the root directory.
  258.   }
  259.  
  260.  
  261. PROCEDURE ChangeDirectory(Dir:pChar);
  262.   {
  263.   PURPOSE  : Changes to the specified directory.
  264.  
  265.   NOTES    : The result is saved in DOSError.
  266.   }
  267.  
  268.  
  269. PROCEDURE ChangeDrive(Drive:Byte);
  270.   {
  271.   PURPOSE  : Changes to the specified drive.
  272.  
  273.   NOTES    : 1 = Drive A
  274.              2 = Drive B
  275.              3 = Drive C
  276.              4 = Drive D
  277.              etc...
  278.  
  279.   SEE ALSO : CurrentDrive
  280.   }
  281.  
  282.  
  283. FUNCTION CorrectPathName(Dest,Raw,Dir,Ext:pChar):pChar;
  284.   {
  285.   PURPOSE  : Generates a string with the proper directory and extension.
  286.  
  287.   PARAMS   : Dest     Destination string.
  288.              Raw      Filespec to process.
  289.              Dir      Default directory is one was not specified.
  290.              Ext      Default extension is one was not specified.
  291.  
  292.   NOTES    : No range checking is performed.
  293.   }
  294.  
  295.  
  296. FUNCTION CurrentDay:Byte;
  297.   {
  298.   PURPOSE  : Returns the current day number of the month.
  299.  
  300.   SEE ALSO : CurrentMonth, CurrentWeekday, CurrentYear
  301.   }
  302.  
  303.  
  304. FUNCTION CurrentDrive:Byte;
  305.   {
  306.   PURPOSE  : Returns the curre